package com.example.gokchinesefoodmapmcdev.util;

import java.util.HashMap;

/**
 * 自定义结果集
 * 存放 响应码code、返回信息msg、返回数据data
 */
public class ResultData extends HashMap {

    /**
     * 自定义验证成功响应码
     */
    public static final int VERIFY_SUCCESS = 200;

    /**
     * 自定义验证失败响应码
     */
    public static final int VERIFY_FAIL = 201;

    /**
     * 自定义注册成功响应码
     */
    public static final int REGISTER_SUCCESS = 0;

    /**
     * 自定义注册失败响应码
     */
    public static final int REGISTER_FAIL = 1;

    /**
     * 自定义操作成功响应码
     */
    public static final int OPERATION_SUCCESS = 0;

    /**
     * 自定义操作失败响应码
     */
    public static final int OPERATION_FAIL = 500;


    public ResultData(){

    }
    public ResultData(int code, String msg) {
//        this.code = code;
//        this.msg = msg;
//        this.data = data;
        this.put("code",code);
        this.put("msg",msg);
    }



    public ResultData(int code, String msg, Object data) {
        this.put("code", code);
        this.put("msg", msg);
        this.put("data", data);
    }

    public static ResultData ok() {
        return new ResultData(VERIFY_SUCCESS, "验证成功！", null);
    }

    public static ResultData ok(int code, String msg) {
        return new ResultData(code, msg, null);
    }

    public static ResultData fail() {
        return new ResultData(VERIFY_FAIL, "验证失败！", null);
    }

    public static ResultData fail(int code, String msg) {
        return new ResultData(code, msg, null);
    }

}
